package com.ruoyi.scenery.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.scenery.domain.SceneryMeasure;
import com.ruoyi.scenery.service.ISceneryMeasureService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 特殊情况措施管理Controller
 * 
 * @author ruoyi
 * @date 2023-04-09
 */
@RestController
@RequestMapping("/scenery/measure")
public class SceneryMeasureController extends BaseController
{
    @Autowired
    private ISceneryMeasureService sceneryMeasureService;

    /**
     * 查询特殊情况措施管理列表
     */
    @PreAuthorize("@ss.hasPermi('scenery:measure:list')")
    @GetMapping("/list")
    public TableDataInfo list(SceneryMeasure sceneryMeasure)
    {
        startPage();
        List<SceneryMeasure> list = sceneryMeasureService.selectSceneryMeasureList(sceneryMeasure);
        return getDataTable(list);
    }

    /**
     * 导出特殊情况措施管理列表
     */
    @PreAuthorize("@ss.hasPermi('scenery:measure:export')")
    @Log(title = "特殊情况措施管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SceneryMeasure sceneryMeasure)
    {
        List<SceneryMeasure> list = sceneryMeasureService.selectSceneryMeasureList(sceneryMeasure);
        ExcelUtil<SceneryMeasure> util = new ExcelUtil<SceneryMeasure>(SceneryMeasure.class);
        util.exportExcel(response, list, "特殊情况措施管理数据");
    }

    /**
     * 获取特殊情况措施管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('scenery:measure:query')")
    @GetMapping(value = "/{sceneryCaseId}")
    public AjaxResult getInfo(@PathVariable("sceneryCaseId") Long sceneryCaseId)
    {
        return success(sceneryMeasureService.selectSceneryMeasureBySceneryCaseId(sceneryCaseId));
    }

    /**
     * 新增特殊情况措施管理
     */
    @PreAuthorize("@ss.hasPermi('scenery:measure:add')")
    @Log(title = "特殊情况措施管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SceneryMeasure sceneryMeasure)
    {
        return toAjax(sceneryMeasureService.insertSceneryMeasure(sceneryMeasure));
    }

    /**
     * 修改特殊情况措施管理
     */
    @PreAuthorize("@ss.hasPermi('scenery:measure:edit')")
    @Log(title = "特殊情况措施管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SceneryMeasure sceneryMeasure)
    {
        return toAjax(sceneryMeasureService.updateSceneryMeasure(sceneryMeasure));
    }

    /**
     * 删除特殊情况措施管理
     */
    @PreAuthorize("@ss.hasPermi('scenery:measure:remove')")
    @Log(title = "特殊情况措施管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{sceneryCaseIds}")
    public AjaxResult remove(@PathVariable Long[] sceneryCaseIds)
    {
        return toAjax(sceneryMeasureService.deleteSceneryMeasureBySceneryCaseIds(sceneryCaseIds));
    }
}
